class ErrConst extends Exception{
	private int val;
	public ErrConst(){
		super();
		val=0;
	}
	public ErrConst(int n){
		super();
		val=n;
	}
	
	public int getVal(){
		return val;
	}
}

class ErrModif extends Exception{
	private int val;
	public ErrModif(){
		super();
		val=0;
	}
	public ErrModif(int n){
		super();
		val=n;
	}
	
	public int getVal(){
		return val;
	}
}

public class EntNat {
	private int m_a;
	
	public EntNat(int a) throws ErrConst{
		if (a<0) throw new ErrConst(a);
		m_a=a;
	}
	
	public int getN(){
		return m_a;
	}
	
	public void setN(int a) throws ErrModif{
		if (a<0) throw new ErrModif(a);
		m_a=a;
	}
	
	public int decremente() throws ErrModif{
		setN(m_a-1);
		return m_a;
	}
	
	public static EntNat decremente(EntNat e) throws ErrModif,ErrConst{
		return new EntNat(e.decremente());
	}
	
	//METHODE MAIN
	public static void main(String[] args) {
		
		try {
			EntNat e1=new EntNat(-3);
			EntNat e2=new EntNat(e1.decremente());
		}
		
		catch(ErrConst ec){
			System.err.println("Error const : paramètre "+ec.getVal()+" non valide");
		}
		catch(ErrModif em){
			System.err.println("Error modif : paramètre de modification de fonction "+em.getVal()+" non valide");
		}
	}

}
